var xmlHttp;

function thumbs(id,t) {
	//document.getElementById('throbber-verify').style.visibility = 'visible';
	t = parseInt(t);
	if (isNaN(t)) {
		return;
	}
	
	if(t!=1 && t!=-1 && t!=2){
		return;
	}
	
	id = parseInt(id);
	if (isNaN(id)) {
		return;
	}
	
	var url = "./utils/thumbs.php?id=" + id + "&t=" + t;

	xmlHttp = GetXmlHttpObject();
	if (xmlHttp == null) {
		alert ("Browser does not support Http Request");
		return;
	}

	xmlHttp.open("GET", url, true);
	xmlHttp.send(null);
	xmlHttp.onreadystatechange = stateChanged;
}

function stateChanged() {
	if (xmlHttp.readyState == 4 || xmlHttp.readyState == "complete") {
		var rsp = xmlHttp.responseText;
		if(rsp == 1 || rsp == "1"){
			if (document.getElementById("divMsg")) {
				// thumbs up
				document.getElementById("divMsg").innerHTML = "帖主感谢您的支持...";
			}
			if (document.getElementById("divThumbs")) {
				document.getElementById("divThumbs").style.visibility = 'hidden';
			}
		}else if(rsp == -1 || rsp == "-1"){
			if (document.getElementById("divMsg")) {
				// thumbs down
				document.getElementById("divMsg").innerHTML = "帖主感到很郁闷...";
			}
			if (document.getElementById("divThumbs")) {
				document.getElementById("divThumbs").style.visibility = 'hidden';
			}
		}else if(rsp == 2 || rsp == "2"){
			if (document.getElementById("divMsg")) {
				// thumbs down
				document.getElementById("divMsg").innerHTML = "帖主感谢您送的鲜花...";
			}
			if (document.getElementById("divThumbs")) {
				document.getElementById("divThumbs").style.visibility = 'hidden';
			}
		}
		//document.getElementById('throbber-verify').style.visibility = 'hidden';
	}
}

function GetXmlHttpObject() {
	var xmlHttp = null;

	try {
		// Firefox, Opera 8.0+, Safari
		xmlHttp = new XMLHttpRequest();
	} catch (e) {
		// Internet Explorer
		try {
			xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return xmlHttp;
}
